#!/bin/bash
SERVERS="192.168.100.184"
PASSWORD=1234qwer


auto_ssh_copy_file() {
    expect -c "set timeout -1;
        spawn scp -P22 -r /var/projects/docker/jar-list root@$1:/data/bolt/docker;
        expect {
            *(yes/no)* {send -- yes\r;exp_continue;}
            *assword:* {send -- $2\r;exp_continue;}
            eof        {exit 0;}
        }";
}

# 循环所有的机器,开始copy
ssh_copy_id_to_all() {
    for SERVER in $SERVERS
        do
            auto_ssh_copy_file $SERVER $PASSWORD
        done
}
ssh_copy_id_to_all
